<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; color:#000000; background-color:#f8f9fa;">Словари (dict) в Python: создание, основные методы, функции и операции</span></p>
<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> 14.03.2022</li>
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> 197</li>
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> <a href="https://fullstacker.ru/category/python-base"><span style=" text-decoration: underline; color:#0000ff;">Основы Python</span></a></li>
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> <a href="https://fullstacker.ru/tag/python-data-types"><span style=" text-decoration: underline; color:#0000ff;">Типы данных</span></a></li>
<li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> <a href="https://fullstacker.ru/tag/python-dict"><span style=" text-decoration: underline; color:#0000ff;">Словари</span></a></li></ul>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">Словарь (dictionary) — тип данных в Python состоящий из набора элементов с доступом по ключу.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Словари также называют ассоциативными массивами или хеш-таблицами.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">В словарях данные хранятся в виде пар ключ-значение</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">{</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">key</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">:</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">value</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">}</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D1%81%D0%B8%D0%BD%D1%82%D0%B0%D0%BA%D1%81%D0%B8%D1%81-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">С</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">интаксис словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Словари в Python выглядят следующим образом:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas';"> ключ</span><span style=" font-family:'Consolas'; color:#990055;">1</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';">значение</span><span style=" font-family:'Consolas'; color:#990055;">1</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> ключ</span><span style=" font-family:'Consolas'; color:#990055;">2</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';">значение</span><span style=" font-family:'Consolas'; color:#990055;">2</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">....}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Ключи — всегда уникальные, они должны быть неизменяемого типа (</span><a href="https://fullstacker.ru/stroki-v-python-metody-funktsii-i-formatirovanie"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; text-decoration: underline; color:#000000;">строки</span></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">, числа)<br />Значения — могут быть любыми и необязательно уникальными.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'ru'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Россия'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'au'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Австралия'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'is'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Исландия'</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">type</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#&lt;class 'dict'&gt;</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">П</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">рименение словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Основное применение словаря — это хранение в нем значений с ключами и получение доступа к этим значениям по заданным ключам.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">С</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">оздание словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 1. Создание словаря с помощью фигурных скобок</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'key1'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'value1'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key2'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'value2'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key3'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'value3'</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Словари могу быть вложенными (т.е. словари внутри словарей):</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#990055;">1</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">},</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#990055;">2</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{1: {'Sasha': 35}, 2: {'Maxim': 30}}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 2. Создание словаря с помощью функции dict()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Функция принимает переменные со значениями и создает из них словарь:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">Sasha</span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> Maxim</span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> Ivan</span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Также эта функция работает и со списком кортежей из двух элементов (которые будут преобразованы в ключ:значение):</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[(</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">),</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">),</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">)]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_list</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Или со вложенными списками:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[[</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">],</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">],</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">]]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_list</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 3. Создание словаря с помощью метода dict.fromkeys(list, value)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">В этом случае каждый ключ будет иметь одно и то же заданное значение:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'key1'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key2'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key3'</span><span style=" font-family:'Consolas'; color:#999999;">]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">fromkeys</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_list</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">555</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'key1': 555, 'key2': 555, 'key3': 555}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Из списка берутся элементы, далее этот метод делает их ключами словаря, а значениями будут аргумент</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">value</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Если его не указать, то получится такой словарь:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'key1'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key2'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key3'</span><span style=" font-family:'Consolas'; color:#999999;">]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">fromkeys</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_list</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'key1': None, 'key2': None, 'key3': None}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 4. Создание словаря с помощью функции zip() вызванной внутри функции dict()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Для этого нужно два списка, один будет ключами словаря, а второй список — значениями. Если длина списков не совпадет, лишнее просто не будет использоваться для создания словаря.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">key_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'key1'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key2'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'key3'</span><span style=" font-family:'Consolas'; color:#999999;">]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">value_list </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'value1'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'value2'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'value3'</span><span style=" font-family:'Consolas'; color:#999999;">]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">dict</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">zip</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">key_list</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> value_list</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 5. Создание словаря с помощью генератора словарей</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Создадим простой словарь в цикле:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas';">a</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> a </span><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> a </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">range</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#990055;">5</span><span style=" font-family:'Consolas'; color:#999999;">)}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{0: 0, 1: 1, 2: 2, 3: 3, 4: 4}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Мы создали числовой диапазон</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">range</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> от 0 до 4 и в словарь добавили ключи и значения от 0 до 4 циклом.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas';">a</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> a</span><span style=" font-family:'Consolas'; color:#9a6e3a;">+</span><span style=" font-family:'Consolas'; color:#990055;">1</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> a </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">range</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#990055;">5</span><span style=" font-family:'Consolas'; color:#999999;">)}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{0: 1, 1: 2, 2: 3, 3: 4, 4: 5}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Здесь ключами словаря мы сделали числа из</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">range</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">, а значениям добавили +1.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0-%D1%81%D0%BE-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F%D0%BC%D0%B8-%D0%B2-python"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">Р</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">абота со словарями в Python</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B9-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">П</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">олучение значений словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Для того, чтобы получить значение словаря необходимо обратиться к ключу. Просто указать ключ в квадратных скобках.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">])</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#30</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Если обратиться к словарю по несуществующему ключу, то получим ошибку:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">])</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#builtins.KeyError: 'Petr'</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Чтобы не получать таких ошибок при обращении по несуществующему ключу можно использовать метод</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">get</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">(</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">key</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">[,</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;"> default</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">])</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">.<br />Если запрошенного ключа не будет в словаре, то метод вернет </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">default</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">, если он не указан, то вернет </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#990055; background-color:#f0f1f3;">None</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">get</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Not found'</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Not found</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">get</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#None</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%B4%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%BD%D0%BE%D0%B2%D0%BE%D0%B3%D0%BE-%D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%B0-%D0%B2-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8C"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">Д</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">обавление нового элемента в словарь</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Чтобы добавить одиночный элемент в словарь нужно просто добавить новую пару ключ:значение:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">]</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">25</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Petr': 25}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Чтобы добавить сразу несколько элементов в словарь можно использовать метода</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">update</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">([</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">other</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">])</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">В</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">other</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> передаем словарь, которые нужно добавить в существующий словарь:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">update</span><span style=" font-family:'Consolas'; color:#999999;">({</span><span style=" font-family:'Consolas'; color:#669900;">'Nikita'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">33</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Roma'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">18</span><span style=" font-family:'Consolas'; color:#999999;">})</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Nikita': 33, 'Roma': 18}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Или именованные аргументы:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">update</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">Nikita</span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas'; color:#990055;">33</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> Roma</span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas'; color:#990055;">18</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Nikita': 33, 'Roma': 18}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Или список кортежей:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">update</span><span style=" font-family:'Consolas'; color:#999999;">([(</span><span style=" font-family:'Consolas'; color:#669900;">'Nikita'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">33</span><span style=" font-family:'Consolas'; color:#999999;">),</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Roma'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">18</span><span style=" font-family:'Consolas'; color:#999999;">)])</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Nikita': 33, 'Roma': 18}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BE%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%81%D1%83%D1%89%D0%B5%D1%81%D1%82%D0%B2%D1%83%D1%8E%D1%89%D0%B5%D0%B3%D0%BE-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B2-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D0%B5"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">О</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">бновление существующего значения в словаре</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Для этого обращаемся к значению по ключу и передаем новое значение:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">]</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">40</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 40}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Чтобы обновить сразу несколько значений в словаре, используем метод</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">update</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">([</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">other</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">])</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">update</span><span style=" font-family:'Consolas'; color:#999999;">({</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">45</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">40</span><span style=" font-family:'Consolas'; color:#999999;">})</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 45, 'Maxim': 40, 'Ivan': 20}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D1%83%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%BE%D0%B2-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">У</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">даление элементов словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Есть несколько способов удаления элементов из словаря.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 1. Удаление элемента с помощью оператора del</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Указываем оператор</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#0077aa; background-color:#f0f1f3;">del</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">, далее имя словаря и в квадратных скобках ключ, после выполнения запись с этим ключем будет удалена:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">del</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">[</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 2. Удаление элемента с помощью метода dict.pop(key[, default])</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">pop</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Если удаляемого ключа нет в словаре, получим</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">default</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">, а если </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">default</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> не задан, то будет ошибка KeyError:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">pop</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#builtins.KeyError: 'Petr'</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">item </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">pop</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Not found'</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">item</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Not found</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Также этот метод возвращает значение, которое было удалено из словаря:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">item </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">pop</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">item</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#20</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Способ 3. Удаление последнего элемента словаря методом dict.popitem()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">popitem</span><span style=" font-family:'Consolas'; color:#999999;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BE%D1%87%D0%B8%D1%81%D1%82%D0%B8%D1%82%D1%8C-%D0%B8-%D1%83%D0%B4%D0%B0%D0%BB%D0%B8%D1%82%D1%8C-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8C-%D1%86%D0%B5%D0%BB%D0%B8%D0%BA%D0%BE%D0%BC"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">О</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">чистить и удалить словарь целиком</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Для того, чтобы полностью удалить весь словарь используется оператор</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#0077aa; background-color:#f0f1f3;">del</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">del</span><span style=" font-family:'Consolas';"> my_dict</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#builtins.NameError: name 'my_dict' is not defined</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Чтобы удалить все значения словаря используется метод</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">clear</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">()</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">clear</span><span style=" font-family:'Consolas'; color:#999999;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0-%D0%BD%D0%B0%D0%BB%D0%B8%D1%87%D0%B8%D1%8F-%D0%BA%D0%BB%D1%8E%D1%87%D0%B0-%D0%B2-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D0%B5"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">П</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:large; font-weight:496; color:#444444; background-color:#f8f9fa;">роверка наличия ключа в словаре</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Для того, чтобы узнать есть ли нужный ключ в словаре используется оператор</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#0077aa; background-color:#f0f1f3;">in</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#True</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Если ключа в словаре нет, то вернется</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#990055; background-color:#f0f1f3;">False</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Roma'</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#False</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%B4%D1%80%D1%83%D0%B3%D0%B8%D0%B5-%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D0%B5%D0%B9"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">Д</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">ругие методы словарей</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Получить список кортежей пар словаря ключ:значение</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">items</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">items</span><span style=" font-family:'Consolas'; color:#999999;">())</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#dict_items([('Sasha', 35), ('Maxim', 30), ('Ivan', 20)])</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Получить список ключей словаря</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">keys</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">keys</span><span style=" font-family:'Consolas'; color:#999999;">())</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#dict_keys(['Sasha', 'Maxim', 'Ivan'])</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Получить список значений словаря</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">values</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">values</span><span style=" font-family:'Consolas'; color:#999999;">())</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#dict_values([35, 30, 20])</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Создание копии словаря</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">copy</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict_2 </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">copy</span><span style=" font-family:'Consolas'; color:#999999;">()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict_2</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Получить значение ключа и если его нет, то создать</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">.</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">setdefault</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">(</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">key</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">[,</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;"> default</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">])</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Метод проверяет, есть ли значение у ключа, если есть то возвращает его, если нет, то создает новый элемент словаря с ключом</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">key</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> и значением </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#000000; background-color:#f0f1f3;">default</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> (по умолчанию None):</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">setdefault</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#None</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Petr': None}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">setdefault</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">'Petr'</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">50</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#50</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#{'Sasha': 35, 'Maxim': 30, 'Ivan': 20, 'Petr': 50}</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BE%D1%81%D0%BD%D0%BE%D0%B2%D0%BD%D1%8B%D0%B5-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D0%B5%D0%B9"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">О</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">сновные функции словарей</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Длина словаря</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">len</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">(</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Под</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> </span><a href="https://fullstacker.ru/kak-opredelit-dlinu-slovarya-v-python"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; text-decoration: underline; color:#000000;">длиной словаря</span></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;"> в Python подразумевается количество пар ключ:значение:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">len</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#3</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Сортировка словаря</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">: </span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">sorted</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">(</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#669900; background-color:#f0f1f3;">dict</span><span style=" font-family:'Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace'; font-size:16px; color:#999999; background-color:#f0f1f3;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Получим сортированный список ключей словаря:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas'; color:#669900;">sorted</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">my_dict</span><span style=" font-family:'Consolas'; color:#999999;">))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#['Ivan', 'Maxim', 'Sasha']</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:1.2%; background-color:#f8f9fa;"><a name="%D0%BF%D0%B5%D1%80%D0%B5%D0%B1%D0%BE%D1%80-%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8F"></a><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">П</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:x-large; font-weight:496; color:#444444; background-color:#f8f9fa;">еребор словаря</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Перебор ключей словаря с помощью цикла for</span><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> key </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">key</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Sasha</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Maxim</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Ivan</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Перебор словаря с помощью цикла for и метода dict.items()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> k</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> v </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">items</span><span style=" font-family:'Consolas'; color:#999999;">():</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">k</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> v</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Sasha 35</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Maxim 30</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Ivan 20</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Перебор словаря с помощью цикла for и метода dict.keys()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Получим ключи словаря:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> key </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">keys</span><span style=" font-family:'Consolas'; color:#999999;">():</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">key</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Sasha</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Maxim</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#Ivan</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; font-weight:600; color:#444444;">Перебор словаря с помощью цикла for и метода dict.values()</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#f8f9fa;"><span style=" font-family:'system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji'; font-size:16px; color:#444444; background-color:#f8f9fa;">Получим значения словаря:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">my_dict </span><span style=" font-family:'Consolas'; color:#9a6e3a;">=</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#999999;">{</span><span style=" font-family:'Consolas'; color:#669900;">'Sasha'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">35</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Maxim'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">30</span><span style=" font-family:'Consolas'; color:#999999;">,</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#669900;">'Ivan'</span><span style=" font-family:'Consolas'; color:#999999;">:</span><span style=" font-family:'Consolas';"> </span><span style=" font-family:'Consolas'; color:#990055;">20</span><span style=" font-family:'Consolas'; color:#999999;">}</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#0077aa;">for</span><span style=" font-family:'Consolas';"> values </span><span style=" font-family:'Consolas'; color:#0077aa;">in</span><span style=" font-family:'Consolas';"> my_dict</span><span style=" font-family:'Consolas'; color:#999999;">.</span><span style=" font-family:'Consolas';">values</span><span style=" font-family:'Consolas'; color:#999999;">():</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">    </span><span style=" font-family:'Consolas'; color:#0077aa;">print</span><span style=" font-family:'Consolas'; color:#999999;">(</span><span style=" font-family:'Consolas';">values</span><span style=" font-family:'Consolas'; color:#999999;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#35</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#30</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; color:#708090;">#20</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p></body></html>